<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>用户评论电影页面</title>
    <link th:href="@{/showstatic/css/details.css}" type="text/css" rel="stylesheet"/>
    <link th:href="@{/showstatic/js/layer-v3.0.3/layer/mobile/need/layer.css}" rel="stylesheet" type="text/css"/>
    <link th:href="@{/showstatic/layui/css/layui.css}" type="text/css" rel="stylesheet"/>
    <script type="text/javascript" th:src="@{/showstatic/js/jquery-1.7.2.min.js}"></script>
    <script type="text/javascript" th:src="@{/showstatic/js/phone.js}"></script>
    <script type="text/javascript" th:src="@{/showstatic/js/layer-v3.0.3/layer/layer.js}"></script>
    <script type="text/javascript" th:src="@{/showstatic/layui/layui.js}"></script>
</head>

<body>

<div class="whole">
    <div style="margin-left: 20px;margin-top: 20px;"><i class="layui-icon layui-icon-return" style="color: black;font-size: 50px" onclick="backindex()"></i></div>
    <div style="padding: 40px"></div>
    <div class="detail">
        <div class="bol"><img src="/showstatic/image/bg-bg.png"/></div>
        <div class="det-con">
            <div class="common det-c">
                <div class="jz-pic">
                    <img th:src="${movieinfo.img}"/>
                </div>
                <div class="det-inf" style="margin-left: 20px">
                    <p class="det-titles">
                        <span>[[${movieinfo.movename}]]</span>
                        <span class="eng">选择评分</span>
                    </p>
                   <!-- 星级-->
                    <div id="starnum" style="font-size: 20px">

                    </div>
                </div>
            </div>
        </div>
        <!--评论框-->
        <div style="margin-left: 30px;margin-top: -5px">
            <textarea id="commenttext" rows="5" cols="95" placeholder="请留下亲的评价"></textarea>
        </div>
    </div>
    <div style="margin-top: 50px;height: 10px" >
        <a class="footer" onclick="sunmitComment()">提交评论</a>
    </div>
</div>

<script th:inline="javascript">
    var url = [[@{/}]];
    var movieId = [[${movieId}]];        //影片id
    var ordernumber = [[${ordernum}]];   //对应的订单号
</script>
<!--动态星星函数-->
<script>
    var starnum;   //星数
    layui.use(['rate'], function() {
        rate = layui.rate;
        //显示文字
        rate.render({
            elem: '#starnum',
            value:0,      //初始值
            text: true,    //开启文本
            choose: function(value){
                starnum = value;
                if(value > 4) alert( '么么哒' )
            }
        });
    });

    //提交评论
    function sunmitComment() {
        // alert("电影id："+movieId);
        //获取评论内容
        var commenttext = $("#commenttext").val();
        //校验评论内容
        commenttext = $.trim(commenttext);
        if(commenttext.length==0){
            alert("请输入有效的评论");
        }else{
            //发送请求
            $.ajax({
                url:url+"comment/addComment",
                type:"post",
                data:{
                   "commentstar":starnum,
                   "commenttext":commenttext,
                   "movieId":movieId,
                   "orderNum":ordernumber
                },
                success:function(result){
                   if(result.code==200){
                      //此处应该返回用户的评论页面.发送请求查看该用户的所有评论
                       window.location.href=url+"comment/findComentByUid";
                   }else{
                      alert(result.msg);
                   }
                }
            })
        }
    }
    //返回我的订单页面。该处是直接跳转到我的订单页面
    function backindex() {
        window.location.href=url+"movieshow/userorder";
    }
</script>
</body>
</html>
